package com.awenhui.demo.task;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Component;

import javax.validation.Valid;

/**
 * @author yuxf
 * @version 1.0
 * @date 2021/1/27 17:34
 */
@Component
public class Task01 implements SchedulingConfigurer {

    @Value("${task.task01}")
    private String task01Cron;

    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.addCronTask(new Runnable() {
            @Override
            public void run() {
                System.out.println("SchedulingConfigurer:"+task01Cron);
            }
        }, task01Cron);
    }
}
